Skip to content

test(integration): add otherField column to protect-ci fixture#403

Open
coderdan wants to merge 1 commit intomainfrom
dan/protect-ci-other-field
Open

test(integration): add otherField column to protect-ci fixture#403
coderdan wants to merge 1 commit intomainfrom
dan/protect-ci-other-field

Conversation

@coderdan
Copy link
Copy Markdown
Contributor

@coderdan coderdan commented May 4, 2026

Summary

  • The supabase test suites write a non-encrypted `otherField` text column to `protect-ci`. PR test(integration): self-create the protect-ci fixture table #400's union schema missed it, so PR chore(deps)(deps): bump vite from 6.4.1 to 8.0.9 #393's CI fails on the supabase suite with `Could not find the 'otherField' column`.
  • Add the column to all three `CREATE TABLE IF NOT EXISTS` bodies (drizzle, protect/supabase, stack/supabase).
  • Also add an `ALTER TABLE ADD COLUMN IF NOT EXISTS` so long-lived CI databases — where the CREATE is a no-op — get the column backfilled on the next test run, no manual DBA step needed.

Test plan

Summary by CodeRabbit

  • Tests
    • Updated test database infrastructure to ensure consistent schema setup across test runs.

The supabase test suites (packages/protect/__tests__/supabase.test.ts,
packages/stack/__tests__/supabase.test.ts) write a non-encrypted
'otherField' text column to 'protect-ci' that PR #400's union schema
missed.

Add it to all three CREATE TABLE IF NOT EXISTS bodies (drizzle plus the
two supabase suites). Add an ALTER TABLE ADD COLUMN IF NOT EXISTS so
long-lived CI databases — where CREATE TABLE IF NOT EXISTS is a no-op —
get the column backfilled the next time any suite runs.
@coderdan coderdan requested a review from a team as a code owner May 4, 2026 09:52
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 4, 2026

⚠️ No Changeset found

Latest commit: 9f49103

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

📝 Walkthrough

Walkthrough

Three test fixture files across the drizzle, protect, and stack packages are updated to add an otherField TEXT column to the shared protect-ci database table. Each file updates both the CREATE TABLE IF NOT EXISTS schema and adds an ALTER TABLE backfill step for long-lived CI databases.

Changes

Test Fixture Schema Update

Layer / File(s) Summary
Test Fixture DDL
packages/drizzle/__tests__/drizzle.test.ts, packages/protect/__tests__/supabase.test.ts, packages/stack/__tests__/supabase.test.ts
All three test files update the protect-ci table schema in their beforeAll setup to include otherField TEXT in the initial CREATE TABLE IF NOT EXISTS definition and add an explicit ALTER TABLE "protect-ci" ADD COLUMN IF NOT EXISTS "otherField" TEXT backfill statement to ensure the column exists on pre-existing CI database tables.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes


🐰 A column hops in, so neat and new,
Three tables wake with fields that grew,
Where CI databases once stood bare,
Now otherField blooms everywhere! 🌱

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding an otherField column to the protect-ci fixture across test files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dan/protect-ci-other-field

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/drizzle/__tests__/drizzle.test.ts (1)

125-143: ⚡ Quick win

Consider centralizing the shared protect-ci DDL into a single helper.

This PR exists precisely because the union schema DDL was kept in sync manually across three files and a column was missed in one of them (PR #400). Extracting the CREATE TABLE IF NOT EXISTS + ALTER TABLE ADD COLUMN IF NOT EXISTS block into a shared test-fixture helper (e.g., packages/test-helpers/setupProtectCi.ts) would make any future column addition a one-line change and eliminate drift by construction.

💡 Suggested approach
// packages/test-helpers/setupProtectCi.ts (new file)
+ import postgres from 'postgres'
+
+ export async function setupProtectCiTable(databaseUrl: string): Promise<void> {
+   const sql = postgres(databaseUrl, { prepare: false })
+   try {
+     await sql`
+       CREATE TABLE IF NOT EXISTS "protect-ci" (
+         id INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
+         email eql_v2_encrypted,
+         age eql_v2_encrypted,
+         score eql_v2_encrypted,
+         profile eql_v2_encrypted,
+         encrypted eql_v2_encrypted,
+         "otherField" TEXT,
+         created_at TIMESTAMPTZ DEFAULT NOW(),
+         test_run_id TEXT
+       )
+     `
+     await sql`ALTER TABLE "protect-ci" ADD COLUMN IF NOT EXISTS "otherField" TEXT`
+   } finally {
+     await sql.end()
+   }
+ }

Each beforeAll would then call await setupProtectCiTable(process.env.DATABASE_URL as string) instead of inlining the DDL.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/drizzle/__tests__/drizzle.test.ts` around lines 125 - 143, Extract
the duplicated CREATE TABLE IF NOT EXISTS / ALTER TABLE ADD COLUMN IF NOT EXISTS
block into a single test helper (e.g., export async function
setupProtectCiTable(databaseUrl: string) in
packages/test-helpers/setupProtectCi.ts) and replace the inlined SQL in
packages/drizzle/__tests__/drizzle.test.ts (and the other two test files that
currently inline the same DDL) with a call to await
setupProtectCiTable(process.env.DATABASE_URL as string); ensure the helper opens
a DB client, runs the CREATE TABLE and ALTER TABLE statements exactly as before,
and closes the client so adding future columns is a single change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/drizzle/__tests__/drizzle.test.ts`:
- Around line 125-143: Extract the duplicated CREATE TABLE IF NOT EXISTS / ALTER
TABLE ADD COLUMN IF NOT EXISTS block into a single test helper (e.g., export
async function setupProtectCiTable(databaseUrl: string) in
packages/test-helpers/setupProtectCi.ts) and replace the inlined SQL in
packages/drizzle/__tests__/drizzle.test.ts (and the other two test files that
currently inline the same DDL) with a call to await
setupProtectCiTable(process.env.DATABASE_URL as string); ensure the helper opens
a DB client, runs the CREATE TABLE and ALTER TABLE statements exactly as before,
and closes the client so adding future columns is a single change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 064444ce-0a59-4e79-81cb-6e1688a99d90

📥 Commits

Reviewing files that changed from the base of the PR and between 6e54b8d and 9f49103.

📒 Files selected for processing (3)
  • packages/drizzle/__tests__/drizzle.test.ts
  • packages/protect/__tests__/supabase.test.ts
  • packages/stack/__tests__/supabase.test.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant